package com.bootdo.project.controller;
import com.bootdo.project.domain.TMsg;
import com.bootdo.project.service.impl.TMsgService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;
import com.codegen.vo.Result;
import com.codegen.vo.Page;

import java.util.List;

import org.apache.ibatis.annotations.Param;

/**
 *
 * Created by xxxx on 2019/03/19.
 */
@Controller
@RequestMapping("/tMsg/")
public class TMsgController {

    @Autowired
    TMsgService tMsgService;

    @RequestMapping("selectAll")
    @ResponseBody
    public Result<List<TMsg>> selectAll(){
        return Result.success(tMsgService.selectAll());
    }

    @RequestMapping("select")
    @ResponseBody
    public Result<TMsg> selectByPrimaryKey(Long id){
        return Result.success(tMsgService.selectByPrimaryKey(id));
    }

    @RequestMapping("selectByCondition")
    @ResponseBody
    public Result<List<TMsg>> selectByCondition(TMsg record){
        return Result.success(tMsgService.selectByCondition(record));
    }

    @RequestMapping("count")
    @ResponseBody
    public Result<Integer> count(TMsg record){
        return Result.success(tMsgService.count(record));
    }

    @RequestMapping("insert")
    @ResponseBody
    public Result<Integer> insertSelective(TMsg record){
        return Result.success(tMsgService.insertSelective(record));
    }

    @RequestMapping("update")
    @ResponseBody
    public Result<Integer> updateByPrimaryKeySelective(TMsg record){
        return Result.success(tMsgService.updateByPrimaryKeySelective(record));
    }

    @RequestMapping("selectByPage")
    @ResponseBody
    public Result<Page<List<TMsg>>> selectByPage(Page<TMsg> page){
        List<TMsg> list = null;
        page = page.sequentialDisplayCalculate(tMsgService.count(page.getObj()));
        if (page.getTotalCount() > 0) {
            list = tMsgService.selectByPage(page);
        }
        Page<List<TMsg>> result = new Page<List<TMsg>>(page, list);
        return Result.success(result);
    }

    @RequestMapping("deleteByCondition")
    @ResponseBody
    public Result<Integer> deleteByCondition(TMsg record){
        return Result.success(tMsgService.deleteByCondition(record));
    }

    @RequestMapping("delete")
    @ResponseBody
    public Result<Integer> deleteByPrimaryKey(Long id){
        return Result.success(tMsgService.deleteByPrimaryKey(id));
    }

}
